﻿using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Newtonsoft.Json;

namespace Aesha.WoW.Broker.Model
{
    public class Item
    {
        [JsonProperty("id")]
        public int ItemId { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public int BuyPrice { get; set; }
        public int SellPrice { get; set; }
        public int Stackable { get; set; }
        public string Icon { get; set; }
        public int ItemClass { get; set; }
        public int ItemSubClass { get; set; }
        public int SourceId { get; set; }
        public int MaxCount { get; set; }
        public int Quality { get; set; }
        public int RequiredLevel { get; set; }
        public int RequiredSkill { get; set; }
        public int RequiredSkillRank { get; set; }

        public override string ToString()
        {
            return Name;
        }


        public static EntityTypeConfiguration<Item> Mapping()
        {
            var m = new EntityTypeConfiguration<Item>();

            m.HasKey(t => t.ItemId);
            m.Property(t => t.ItemId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            m.Property(t => t.Name).HasMaxLength(255).IsRequired().IsUnicode(false);
            m.Property(t => t.Description).HasMaxLength(255).IsOptional().IsUnicode(false);
            m.Property(t => t.Icon).HasMaxLength(255).IsOptional().IsUnicode(false);

            return m;
        }
    }
}
